package action;

import com.opensymphony.xwork2.ModelDriven;
import entity.User;
import lombok.Data;
import utils.BaseAction;

import java.util.regex.Pattern;

@Data
public class LoginAction extends BaseAction  {
    private String name;
    private String password;
    //private User user;

    @Override
    public void validate() {
        System.out.println("kk");
        if ("".equals(name)){
            addFieldError("name","用户名不能为空");
        }else if (Pattern.matches("\\w{5,8}",name.trim())){
            addFieldError("name","用户名长度为5-8位");
        }
    }

    @Override
    public String execute(){
        System.out.println("k1");
        return SUCCESS;
    }
}
